import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/**
 * [lazy loading]
 */
const Home = resolve => require(['./views/Home'], resolve)  // 总客流量
// 年龄/性别比例
const SexAgeRatio = resolve => require(['./components/SexAgeRatio'], resolve)
// 各分店到店性别比例
const StoreSexRatio = resolve => require(['./components/StoreSexRatio'], resolve)
// 总客流周高峰时段
const RushHour = resolve => require(['./components/RushHour'], resolve)
// 门店当天客流高峰时段
const StoreRushHour = resolve => require(['./components/StoreRushHour'], resolve)
// 登录
const Login = resolve => require(['./views/Login'], resolve)
const Layout = resolve => require(['./views/Layout'], resolve)

export default new Router({
  routes: [
    {
      path: "/",
      name: "layout",
      component: Layout,
      redirect: { name: 'home' },
      children: [
        {
          path: "/home",
          name: "home",
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: Home
        },
        {
          path: "/sexAgeRatio",
          name: "sexAgeRatio",
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: SexAgeRatio
        },
        {
          path: "/storeSexRatio",
          name: "storeSexRatio",
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: StoreSexRatio
        },
        {
          path: "/rushHour",
          name: "rushHour",
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: RushHour
        },
        {
          path: "/storeRushHour",
          name: "storeRushHour",
          meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
          },
          component: StoreRushHour
        }
      ]
    },
    {
      path: "/login",
      name: "login",
      component: Login
    }
  ]
});
